Skip to content

Conversation

@Shivampal157
Copy link

@Shivampal157 Shivampal157 commented Nov 16, 2025

Closes #87 (UI Enhancement for Sponsorship Modal)

📝 Description

This pull request enhances the UI of the SponsorshipModal component to improve clarity, accessibility, and overall user experience.

The update focuses on:

  • Improving the tab layout and interaction
  • Enhancing visual clarity with better spacing, padding, and active states
  • Increasing accessibility with ARIA roles and keyboard navigation
  • Making the modal more responsive and consistent across all tabs

These improvements ensure the modal feels cleaner, more intuitive, and aligned with modern UI patterns.


🔧 Changes Made

  • Refactored tab buttons with accessible roles (role="tab") and ARIA labels.
  • Added keyboard navigation support (Enter/Space to switch tabs).
  • Updated styling for active/hover states.
  • Enhanced spacing, padding, and typography for improved readability.
  • Cleaned unused JSX and improved semantic structure.
  • Applied consistent UI patterns for:
    • Overview
    • Requirements
    • Brand Info
    • Analytics

📷 Screenshots (Before & After)

Before

before

After

after

🤝 Collaboration

Collaborated with: @AOSSIE-Org maintainers (review pending)


✅ Checklist

  • I have read the contributing guidelines.
  • UI changes tested locally.
  • No breaking changes introduced.
  • Code is clean and commented where needed.

Summary by CodeRabbit

  • New Features
    • Added a Sponsorship modal with overlay, multiple ways to close (button, backdrop, Esc) and focus restoration.
    • Four-tab interface (Overview, Requirements, Brand Info, Analytics) with full keyboard navigation and ARIA accessibility.
    • Displays campaign details with match-score header, contact action, and a fallback campaign when none is provided.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 16, 2025

Walkthrough

Adds a new accessible, focus-managed SponsorshipModal React component with a 4-tab interface and dismissal handlers; adjusts app entry (main.tsx) to remove StrictMode, add a runtime root-element check, and simplify some import paths.

Changes

Cohort / File(s) Summary
New SponsorshipModal Component
Frontend/src/components/SponsorshipModal/SponsorshipModal.tsx
Adds a default-exported React/TypeScript component that renders a modal with overlay, saves/restores focus, handles Escape/backdrop/Close-button dismissal, implements a 4-tab interface (Overview, Requirements, Brand Info, Analytics) with ARIA roles and keyboard navigation, and renders campaign data with a mock fallback.
Application entry
Frontend/src/main.tsx
Removes React.StrictMode wrapper, shortens import paths, reorders CSS import, introduces a root variable with a runtime check that throws if missing, and uses createRoot(root) to render the app wrapped by Redux Provider.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant User
    participant App
    participant SponsorshipModal
    participant DOM

    User->>App: triggers open (click)
    App->>SponsorshipModal: render(open=true, onClose)
    SponsorshipModal->>SponsorshipModal: useEffect(open) -> save activeElement, attach Escape/backdrop handlers
    SponsorshipModal->>DOM: focus dialogRef, render overlay + tab buttons + panels
    User->>SponsorshipModal: navigate tabs (click / keyboard)
    SponsorshipModal->>SponsorshipModal: update activeTab, manage focus
    User->>SponsorshipModal: press Escape or click backdrop or click Close
    SponsorshipModal->>App: call onClose()
    SponsorshipModal->>SponsorshipModal: remove listeners, restore previous focus
    SponsorshipModal->>DOM: unmount modal and overlay
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Review focus-save/restore and edge cases in SponsorshipModal.tsx.
  • Verify attachment/removal of Escape and backdrop handlers.
  • Validate ARIA roles and full keyboard handling for tab list.
  • Confirm runtime root-element check in main.tsx and intentional removal of StrictMode.

Poem

A rabbit peeks in with a curious hop, 🐇
"Tabs and focus — set nicely on top!"
Click, arrow, Escape — the dialog replies,
Close folds the curtain beneath friendly skies. ✨

Pre-merge checks and finishing touches

❌ Failed checks (3 warnings)
Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR objectives state the focus is on enhancing SponsorshipModal UI with accessibility and styling improvements, but linked issue #87 requires custom scrollbar styling across the app using WebKit properties and gradients, which is not implemented in these file changes. Implement custom scrollbar styling in App.css and index.css with WebKit pseudo-elements, pink-to-purple gradients (#fc5fff → #764e95), 8px width, 3px border-radius, and hover effects as specified in issue #87.
Out of Scope Changes check ⚠️ Warning Changes to Frontend/src/main.tsx (removing StrictMode, updating imports, adding root checks) are unrelated to SponsorshipModal UI enhancements or scrollbar styling objectives and appear to be out of scope. Review the necessity of main.tsx changes; if unrelated to the PR objectives, revert them to a separate PR or clearly document their purpose and alignment with PR goals.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'updated SponsorshipModel UI' refers to refactoring and enhancing the SponsorshipModal component's UI with accessible roles, keyboard navigation, and improved styling, which aligns with the main changes in the changeset.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 907e347 and 64e2450.

📒 Files selected for processing (1)
  • Frontend/src/components/SponsorshipModal/SponsorshipModal.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • Frontend/src/components/SponsorshipModal/SponsorshipModal.tsx

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (5)
Frontend/src/components/SponsorshipModal/SponsorshipModal.tsx (3)

19-34: Add defensive check before restoring focus.

Line 33 attempts to restore focus to prevActive without verifying that the element still exists in the DOM or is focusable. If the element was removed while the modal was open, calling focus() could fail silently or throw an error.

Apply this diff to add a defensive check:

     return () => {
       window.removeEventListener("keydown", onKey);
-      prevActive?.focus();
+      if (prevActive && document.contains(prevActive)) {
+        prevActive.focus();
+      }
     };

167-179: Simplify mailto link handling.

Opening a mailto: URL with window.open(mailto, "_blank") is unnecessary and may be blocked by popup blockers. The mailto: protocol doesn't open a new page; it launches the user's email client directly.

Apply this diff to simplify:

             <button
               onClick={() => {
-                // example contact behaviour: open mailto (safe)
                 const mailto = `mailto:[email protected]?subject=Interested in ${encodeURIComponent(
                   t.title || "campaign"
                 )}`;
-                const win = window.open(mailto, "_blank");
-                if (!win) window.location.href = mailto;
+                window.location.href = mailto;
               }}
               className="px-4 py-2 bg-indigo-600 text-white rounded-lg shadow"
             >

18-35: Consider implementing a focus trap.

The current focus management focuses the modal container on open but doesn't prevent users from tabbing out to background content. This violates modal accessibility best practices, as focus should remain trapped within the modal.

Consider using a library like focus-trap-react or implementing a custom focus trap that cycles focus back to the first focusable element when the user tabs past the last element (and vice versa).

Example with focus-trap-react:

import FocusTrap from 'focus-trap-react';

// Wrap modal content:
<FocusTrap>
  <div ref={dialogRef} tabIndex={-1} className="...">
    {/* modal content */}
  </div>
</FocusTrap>
Frontend/src/main.tsx (2)

4-4: Use English for code comments.

The comment contains non-English text (Hindi/Hinglish). For maintainability in an international codebase, all comments should be in English.

Apply this diff:

-import "./index.css"; // agar file nahi hai to hata sakte ho (nahin to leave it)
+import "./index.css"; // can be removed if file doesn't exist

44-45: Root element fallback may cause issues.

Creating and appending a root element to document.body if the #root element doesn't exist could lead to unexpected rendering behavior and makes debugging harder. It's better to fail fast with a clear error if the expected DOM structure is missing.

Apply this diff:

-const rootEl = document.getElementById("root") || document.body.appendChild(document.createElement("div"));
-createRoot(rootEl as HTMLElement).render(<TestApp />);
+const rootEl = document.getElementById("root");
+if (!rootEl) {
+  throw new Error("Root element not found. Ensure index.html contains <div id='root'></div>");
+}
+createRoot(rootEl).render(<TestApp />);
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a3be437 and 3033943.

📒 Files selected for processing (2)
  • Frontend/src/components/SponsorshipModal/SponsorshipModal.tsx (1 hunks)
  • Frontend/src/main.tsx (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
Frontend/src/main.tsx (1)
Frontend/src/components/SponsorshipModal/SponsorshipModal.tsx (1)
  • SponsorshipModal (14-192)
🔇 Additional comments (1)
Frontend/src/main.tsx (1)

1-45: PR objectives don't match the actual changes.

The PR objectives (from linked issue #87) mention implementing custom scrollbar styling with a pink-to-purple gradient in App.css and index.css, but these changes are not present in this PR. Instead, the PR introduces a new SponsorshipModal component and replaces the main application entry point.

Please verify:

  1. Are the scrollbar styling changes in different files not included in this review?
  2. Should this PR be split into separate PRs (one for the modal component, one for scrollbar styling)?
  3. Is the PR description accurate, or does it need to be updated to reflect the actual scope of changes?

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
Frontend/src/components/SponsorshipModal/SponsorshipModal.tsx (1)

123-123: Remove trailing whitespace.

Line 123 contains unnecessary whitespace/empty line within the button element.

Apply this diff:

               >
                 {tt.label}
-              
               </button>
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b1ae1fc and 907e347.

📒 Files selected for processing (1)
  • Frontend/src/components/SponsorshipModal/SponsorshipModal.tsx (1 hunks)
🔇 Additional comments (1)
Frontend/src/components/SponsorshipModal/SponsorshipModal.tsx (1)

97-126: LGTM! ARIA tab pattern correctly implemented.

The tabbed interface now properly implements the ARIA tab pattern with all three improvements from the previous review:

  1. role="tablist" is present (Line 100)
  2. ✅ Arrow key navigation (ArrowRight/Left/Home/End) is implemented via handleTabKeyDown (Line 113)
  3. ✅ The roving tabindex pattern (tabIndex={tab === tt.id ? 0 : -1} on Line 111) is correct per the ARIA Authoring Practices Guide

Note: The previous review's concern about tabIndex={-1} removing inactive tabs from the tab sequence was based on a misunderstanding. The roving tabindex pattern (where only the active tab has tabIndex={0} and inactive tabs have tabIndex={-1}) is the recommended approach in the ARIA APG for tab widgets. Arrow keys allow navigation between tabs, not the Tab key.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant